package com.example.gkcircle.activity;

import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageButton;
import com.camnter.easyslidingtabs.widget.EasySlidingTabs;
import com.example.gkcircle.App;
import com.example.gkcircle.BaseAppCompatActivity;
import com.example.gkcircle.R;
import com.example.gkcircle.adapter.TabsFragmentAdapter;
import com.example.gkcircle.fragment.borrow.BorrowedFragment;
import com.example.gkcircle.fragment.borrow.BorrowingFragment;
import java.util.LinkedList;
import java.util.List;

/**
 * 我的借阅
 * Created by Jehu on 16/4/12.
 */
public class LibraryBorrowActivity extends BaseAppCompatActivity implements View.OnClickListener{

    private EasySlidingTabs easySlidingTabs;
    private ViewPager easyVP;
    private TabsFragmentAdapter adapter;
    private ImageButton mBack;
    List<Fragment> fragments;
    public static final String[] titles = {"当前借阅", "历史借阅"};

    @Override
    protected void initView() {
        setContentView(R.layout.library_borrow_activity);
        this.easySlidingTabs = (EasySlidingTabs) this.findViewById(R.id.library_borrow_easy_sliding_tabs);
        this.easyVP = (ViewPager) this.findViewById(R.id.library_borrow_easy_vp);
        this.mBack = (ImageButton) this.findViewById(R.id.library_borrow_back);
    }

    @Override
    protected void initListener() {
        mBack.setOnClickListener(this);
    }

    @Override
    protected void setData() {
        this.fragments = new LinkedList<>();
        BorrowedFragment borrowedFragment = BorrowedFragment.getInstance();
        BorrowingFragment borrowingFragment = BorrowingFragment.getInstance();
        this.fragments.add(borrowingFragment);
        this.fragments.add(borrowedFragment);
        this.adapter = new TabsFragmentAdapter(this.getSupportFragmentManager(), titles, this.fragments);
        this.easyVP.setAdapter(this.adapter);
        this.easySlidingTabs.setViewPager(this.easyVP);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.library_borrow_back:
                finish();
                break;
        }
    }

}
